package game;

import java.awt.Color;

public class Orco extends Attore {

	private Attore player;
	public Orco(Amministratore amministratore, char glyph, Color color,String name, int maxHp,int hp, int attack, int defense,Arma arma) {
		super(amministratore, glyph,  color, name,  maxHp, hp,  attack,  defense, arma);
		this.player=amministratore.getPlayer();
	}

	
	@Override
	public void update(){
		for(int i=-3;i<=3;i++)
			for(int j=-3;j<=3;j++)
				if((player.x==x+i)&&(player.y==y+j)){
					insegui(player);
					return;
				}
		int mx = (int)(Math.random() * 3) - 1;
		int my = (int)(Math.random() * 3) - 1;
		Attore other = amministratore.attore(x+mx, y+my);
		
		if ((other != null && (other instanceof Orco || other instanceof Boss)))
			return;
		else if((mx!=0)&&(my!=0))
			moveBy(mx, my);
	}
}
